home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / eflibpt4.zip / DEMO / STREAMS / CRC.PAS next >
Pascal/Delphi Source File  |  1996-07-31  |  1KB  |  34 lines

  1. { Borland Pascal Extended Function Library - EFLIB (C) Johan Larsson, 1996
  2.   Demonstration; CRC filters and file streams
  3.  
  4.   EFLIB IS PROTECTED BY THE COPYRIGHT LAW AND MAY NOT BE COPIED, SOLD OR
  5.   MANIPULATED. FOR MORE INFORMATION, SEE PROGRAM MANUAL! THIS DEMONSTRAT-
  6.   ION PROGRAM MAY FREELY BE USED AND DISTRIBUTED.                          }
  7.  
  8.  
  9. uses EFLIBIO, EFLIBTXT;
  10.  
  11. const CRCBuffer = 4096;
  12.  
  13. var CRC : CRC16FilterObjectPointerType;
  14.     Null : NullStreamObjectPointerType;
  15.  
  16. { ParamStr(1) must contain a filename }
  17.  
  18. begin
  19.      { Initialize CRC filter with a file stream as base }
  20.      CRC := New (CRC16FilterObjectPointerType,
  21.                  Initialize (New(FileStreamObjectPointerType,
  22.                              { Base stream }
  23.                              Initialize (ParamStr(1), CRCBuffer))));
  24.                                          { Filename } { Buffer size }
  25.  
  26.      New (Null, Initialize);
  27.  
  28.      CRC^.MoveOut (Null, CRC^.Size);
  29.  
  30.      WriteLn ('The CRC16 is ', StringHexNumber(CRC^.Result), '.');
  31.  
  32.      CRC^.Free; { Dispose filter including base stream }
  33.      Null^.Free; { Dispose the null stream }
  34. end.